package org.tostring.pork;



import java.util.HashMap;

import javax.inject.Inject;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.pork.domain.EmployeesVO;
import org.pork.service.MapService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/location")
public class LocationControl {

	@Inject
	MapService service;
	
	private static final Logger logger = Logger.getLogger(LocationControl.class);
	
	@RequestMapping(method=RequestMethod.GET)
	public String local(){
		
		return "location";
	
	}
	
	@RequestMapping(value="/setLocation", method=RequestMethod.POST)
	@ResponseBody
	public HashMap<String, HashMap<String, Object>> GetLocation(HttpSession session, String latitude, String longitude) {
		
		
		EmployeesVO epVO = (EmployeesVO) session.getAttribute("userLoginInfo");
		
		logger.info(session.getId());
		logger.info(epVO.toString());
		logger.info(latitude);
		logger.info(longitude);
		 
		HashMap<String, HashMap<String, Object>> map = service.setMap(epVO.getEpid(), latitude,longitude);
		logger.info("콘트롤 맵 : " + map);
		
		return map;
		
	}
	
}
